import EventRoute from '../EventRoute'
const routers: EventRoute[] = []
import { isProcessRunningWin } from '../../utils/index'
import store from '../../store/index';
import { shell } from 'electron'

// 退出软件
routers.push(
  new EventRoute('win-close', (api) => {
    // api.app.exit()
    const appName = store.get('appName') || 'lightbox'
    const url = `${appName}://msgtype==quitAiassistant&&show==true`;
    isProcessRunningWin(appName + '.exe').then(running => {
      if (running) {
        console.log('已启动')
        shell.openExternal(url);
      } else  {
        console.log('未启动')
      }
      api.app.quit()
    });
  })
)

export default routers
